package com.trkj.focusonzhuzhou.tipoffAdapter;

import java.util.List;

import com.trkj.focusonzhuzhou.R;
import com.trkj.focusonzhuzhou.tipoff.Pricelist;
import com.trkj.focusonzhuzhou.tipoff.ViewHolder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter {
	private Context context;
	private List<Pricelist> list1;

	public MyAdapter(Context context, List<Pricelist> list1) {
		super();
		this.context = context;
		this.list1 = list1;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list1.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list1.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		final ViewHolder viewHolder;
		if (arg1 == null) {
			arg1 = LayoutInflater.from(context).inflate(R.layout.textviewlist,
					null);
			viewHolder = new ViewHolder();

			viewHolder.titallist = (TextView) arg1.findViewById(R.id.titallist);
			viewHolder.contentlist = (TextView) arg1
					.findViewById(R.id.contentlist);
			viewHolder.img1 = (ImageView) arg1.findViewById(R.id.img1);
//			viewHolder.img2 = (ImageView) arg1.findViewById(R.id.img2);
//			viewHolder.img3 = (ImageView) arg1.findViewById(R.id.img3);
//			viewHolder.img4 = (ImageView) arg1.findViewById(R.id.img4);

			arg1.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) arg1.getTag();
		}

		final Pricelist pl = list1.get(arg0);
		viewHolder.titallist.setText(pl.titallist);
		viewHolder.contentlist.setText(pl.contentlist);
		viewHolder.img1.setImageResource(pl.img1);
//		viewHolder.img2.setImageResource(pl.img2);
//		viewHolder.img3.setImageResource(pl.img3);
//		viewHolder.img4.setImageResource(pl.img4);

		return arg1;
	}

}
